//报表管理系统/报表查询/查看模态框
import React, { Component } from "react";
import { connect } from "dva";

import {
    Form,
    Radio,
    Modal,
    Table,
    Select,
    Cascader,
    DatePicker,
    Dropdown,
    Button,
    Icon,
    message,
    Pagination,
    Input,
    TimePicker
} from "antd";
import moment from "moment";
import request from "../../../../utils/request";
import style from './Examine.less'
const { TextArea } = Input;


//form表单套件
const { MonthPicker, RangePicker, WeekPicker } = DatePicker;


    class Examine extends Component {

    //导出请求
    save = () => {
        console.log(this.props.record.takeTime)
        if(this.props.text == '能源消耗统计表') {
            request(`/hh-management-web/gnhj/energyconsumption/energyConsumptionDayListExcelExport?takeTime=${this.props.record.takeTime}`).then(data => {
                console.log(data)
            })
            window.location.href = `/hh-management-web/gnhj/energyconsumption/energyConsumptionDayListExcelExport?takeTime=${this.props.record.takeTime}`
        }
        if(this.props.text == '土壤处理量统计表') {
            request(`/hh-management-web/gnhj/soilTreatment/soilTreatmentDayListExcelExport?takeTime=${this.props.record.takeTime}`).then(data => {
                console.log(data)
            })
            window.location.href = `/hh-management-web/gnhj/soilTreatment/soilTreatmentDayListExcelExport?takeTime=${this.props.record.takeTime}`
        }
       
    }

        state={
            data: [
                {
                    opertion:'12',
                    remarkText:'21',
                    takeTime:'32',
                    time:'21',
                    useElectric:321,
                    useNaturalGas:32,
                    useWater:32
                   
               
                },
                {
                    opertion:'12',
                    remarkText:'21',
                    takeTime:'32',
                    time:'21',
                    useElectric:321,
                    useNaturalGas:32,
                    useWater:32
                  
                  
                },
                {
                    opertion:'12',
                    remarkText:'21',
                    takeTime:'32',
                    time:'21',
                    useElectric:321,
                    useNaturalGas:32,
                    useWater:32
                  
                 
                }
            ],
            columns: [
                {
                    title: "日期",
                    dataIndex: "takeTime",
                    key: "takeTime",
                    align: "center"
                },
                {
                    title: "时间",
                    dataIndex: "time",
                    key: "time",
                    align: "center"
                },
                {
                    title: "燃气使用量/Nm³",
                    dataIndex: "useNaturalGas",
                    key: "useNaturalGas",
                    align: "center"
                },
                {
                    title: "电耗/KWh",
                    key: "useElectric",
                    dataIndex: "useElectric",
                    align: "center"
                },
                {
                    title: "水耗/t",
                    key: "useWater",
                    dataIndex: "useWater",
                    align: "center",
                   
                },
                {
                    title: "记录人",
                    key: "opertion",
                    dataIndex: "opertion",
                    align: "center",
                   
                },
                {
                    title: "备注",
                    key: "remarkText",
                    dataIndex: "remarkText",
                    align: "center",
                   
                }
            ]
        }
        
        componentWillReceiveProps(){
            if(this.props.text == '能源消耗统计表') {
                this.setState({
                    
                    columns: [
                        {
                            title: "日期",
                            dataIndex: "takeTime",
                            key: "takeTime",
                            align: "center"
                        },
                        {
                            title: "时间",
                            dataIndex: "time",
                            key: "time",
                            align: "center"
                        },
                        {
                            title: "燃气使用量/Nm³",
                            dataIndex: "useNaturalGas",
                            key: "useNaturalGas",
                            align: "center"
                        },
                        {
                            title: "电耗/KWh",
                            key: "useElectric",
                            dataIndex: "useElectric",
                            align: "center"
                        },
                        {
                            title: "水耗/t",
                            key: "useWater",
                            dataIndex: "useWater",
                            align: "center",
                           
                        },
                        {
                            title: "记录人",
                            key: "opertion",
                            dataIndex: "opertion",
                            align: "center",
                           
                        },
                        {
                            title: "备注",
                            key: "remarkText",
                            dataIndex: "remarkText",
                            align: "center",
                           
                        }
                    ]
                })
            }
            if(this.props.text == '土壤处理量统计表') {
                this.setState({
                   
                    columns: [
                        {
                            title: "日期",
                            dataIndex: "takeTime",
                            key: "takeTime",
                            align: "center"
                        },
                        {
                            title: "时间",
                            dataIndex: "times",
                            key: "times",
                            align: "center"
                        },
                        {
                            title: "班组",
                            dataIndex: "banzu",
                            key: "banzu",
                            align: "center"
                        },
                        {
                            title: "土壤处理量",
                            key: "throughput",
                            dataIndex: "throughput",
                            align: "center"
                        },
                        {
                            title: "记录人",
                            key: "opertion",
                            dataIndex: "opertion",
                            align: "center",
                           
                        },
                        {
                            title: "备注",
                            key: "remarkText",
                            dataIndex: "remarkText",
                            align: "center",
                           
                        }
                    ]
                })
            }
        }
        //日期
      
        render() {
           
          
           
            const { visible, onCancel, onCreate, form ,text,record,over} = this.props;
            console.log(this.props.over)
            console.log(text)
          
         
           if(text == "能源消耗统计表") {
            return (
                <div  className={style.modal}>
              <Modal
                destroyOnClose={true}
                  visible={visible}
                  title="能源消耗日统计表"
                  okText="导出"
                  cancelText="关闭"
                  onCancel={onCancel}
                  onOk={this.save}
                 width={900}
                
                 style={{textAlign:'center'}}
                
                
              >
               <div className={style.myTable}>
               <Table
                           
                           columns={this.state.columns}
                           dataSource={this.props.over}
                           align="center"
                            style={{width:'auto'}}
                           bordered={true}
                           pagination={false}
                           size="small"
                         
                       />
                       </div>
              </Modal>
              </div>
          )
           }
           if(text == "土壤处理量统计表") {
            return (
              <Modal
                  destroyOnClose={true}
                  visible={visible}
                  title="土壤处理量日统计表"
                  okText="导出"
                  cancelText="关闭"
                  onCancel={onCancel}
                  onOk={onCreate}
                  width={900}

                 
              >
               <div className={style.myTable}>
                             <Table
                            size="small"
                           columns={this.state.columns}
                           dataSource={this.props.over}
                           align="center"
                           style={{width:'auto'}}
                           bordered={true}
                           pagination={false}
                       />
                       </div>
                 
              </Modal>
          )
           }
           if(text == "土壤修复指标汇总表") {
               return null
           }
          
           
        }
    }


export default connect()(Examine);
